home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / rpm / rpmdav.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-10-22  |  4.9 KB  |  213 lines

  1. #ifndef RPMDAV_H
  2. #define RPMDAV_H
  3.  
  4. /** \ingroup rpmio
  5.  * \file rpmio/rpmdav.h
  6.  */
  7.  
  8. #if defined(_RPMDAV_INTERNAL)
  9. struct __dirstream {
  10.     int fd;            /* File descriptor.  */
  11.     char * data;        /* Directory block.  */
  12.     size_t allocation;        /* Space allocated for the block.  */
  13.     size_t size;        /* Total valid data in the block.  */
  14.     size_t offset;        /* Current offset into the block.  */
  15.     off_t filepos;        /* Position of next entry to read.  */
  16.     pthread_mutex_t lock;    /* Mutex lock for this structure.  */
  17. };
  18. #endif
  19.  
  20. #if !defined(DT_DIR) || defined(__APPLE__)
  21. # define DT_UNKNOWN    0
  22. # define DT_FIFO    1
  23. # define DT_CHR        2
  24. # define DT_DIR        4
  25. # define DT_BLK        6
  26. # define DT_REG        8
  27. # define DT_LNK        10
  28. # define DT_SOCK    12
  29. # define DT_WHT        14
  30. typedef struct __dirstream *    AVDIR;
  31. typedef struct __dirstream *    DAVDIR;
  32. #else
  33. typedef DIR *            AVDIR;
  34. typedef DIR *            DAVDIR;
  35. #endif
  36.  
  37.  
  38. /**
  39.  */
  40. /*@unchecked@*/
  41. extern int avmagicdir;
  42. #define ISAVMAGIC(_dir) (!memcmp((_dir), &avmagicdir, sizeof(avmagicdir)))
  43.  
  44. /**
  45.  */
  46. /*@unchecked@*/
  47. extern int davmagicdir;
  48. #define ISDAVMAGIC(_dir) (!memcmp((_dir), &davmagicdir, sizeof(davmagicdir)))
  49.  
  50. #ifdef __cplusplus
  51. extern "C" {
  52. #endif
  53.  
  54. /**
  55.  * Close an argv directory.
  56.  * @param dir        argv DIR
  57.  * @return         0 always
  58.  */
  59. int avClosedir(/*@only@*/ DIR * dir)
  60.     /*@globals fileSystem @*/
  61.     /*@modifies dir, fileSystem @*/;
  62.  
  63. /**
  64.  * Return next entry from an argv directory.
  65.  * @param dir        argv DIR
  66.  * @return         next entry
  67.  */
  68. /*@dependent@*/ /*@null@*/
  69. struct dirent * avReaddir(DIR * dir)
  70.     /*@globals fileSystem @*/
  71.     /*@modifies fileSystem @*/;
  72.  
  73. /**
  74.  * Create an argv directory from URL collection.
  75.  * @param path        URL for collection path
  76.  * @return         argv DIR
  77.  */
  78. /*@null@*/
  79. DIR * avOpendir(const char * path)
  80.     /*@globals fileSystem, internalState @*/
  81.     /*@modifies fileSystem, internalState @*/;
  82.  
  83. /**
  84.  * Send a http request.
  85.  * @param ctrl        
  86.  * @param httpCmd    http command
  87.  * @param httpArg    http command argument (NULL if none)
  88.  * @returns        0 on success
  89.  */
  90. int davReq(FD_t ctrl, const char * httpCmd, /*@null@*/ const char * httpArg)
  91.     /*@globals fileSystem, internalState @*/
  92.     /*@modifies ctrl, fileSystem, internalState @*/;
  93.  
  94. /**
  95.  * Read a http response.
  96.  * @param u
  97.  * @param cntl        
  98.  * @retval *str        error msg        
  99.  * @returns        0 on success
  100.  */
  101. int davResp(urlinfo u, FD_t ctrl, /*@out@*/ /*@null@*/ char *const * str)
  102.     /*@globals fileSystem, internalState @*/
  103.     /*@modifies ctrl, *str, fileSystem, internalState @*/;
  104.  
  105. /**
  106.  */
  107. /*@null@*/
  108. FD_t davOpen(const char * url, /*@unused@*/ int flags,
  109.         /*@unused@*/ mode_t mode, /*@out@*/ urlinfo * uret)
  110.         /*@globals internalState @*/
  111.         /*@modifies *uret, internalState @*/;
  112.  
  113. /**
  114.  */
  115. /*@-incondefs@*/
  116. ssize_t davRead(void * cookie, /*@out@*/ char * buf, size_t count)
  117.         /*@globals fileSystem, internalState @*/
  118.         /*@modifies buf, fileSystem, internalState @*/
  119.     /*@requires maxSet(buf) >= (count - 1) @*/
  120.     /*@ensures maxRead(buf) == result @*/;
  121. /*@=incondefs@*/
  122.  
  123. /**
  124.  */
  125. ssize_t davWrite(void * cookie, const char * buf, size_t count)
  126.         /*@globals fileSystem, internalState @*/
  127.         /*@modifies fileSystem, internalState @*/;
  128.  
  129. /**
  130.  */
  131. int davSeek(void * cookie, _libio_pos_t pos, int whence)
  132.         /*@globals fileSystem, internalState @*/
  133.         /*@modifies fileSystem, internalState @*/;
  134.  
  135. /**
  136.  */
  137. int davClose(void * cookie)
  138.     /*@globals fileSystem, internalState @*/
  139.     /*@modifies cookie, fileSystem, internalState @*/;
  140.  
  141. /**
  142.  */
  143. int davMkdir(const char * path, mode_t mode)
  144.     /*@globals fileSystem, internalState @*/
  145.     /*@modifies fileSystem, internalState @*/;
  146.  
  147. /**
  148.  */
  149. int davRmdir(const char * path)
  150.     /*@globals fileSystem, internalState @*/
  151.     /*@modifies fileSystem, internalState @*/;
  152.  
  153. /**
  154.  */
  155. int davRename(const char * oldpath, const char * newpath)
  156.     /*@globals fileSystem, internalState @*/
  157.     /*@modifies fileSystem, internalState @*/;
  158.  
  159. /**
  160.  */
  161. int davUnlink(const char * path)
  162.     /*@globals fileSystem, internalState @*/
  163.     /*@modifies fileSystem, internalState @*/;
  164.  
  165. /**
  166.  * Close a DAV collection.
  167.  * @param dir        argv DIR
  168.  * @return         0 always
  169.  */
  170. int davClosedir(/*@only@*/ DIR * dir)
  171.     /*@globals fileSystem @*/
  172.     /*@modifies dir, fileSystem @*/;
  173.  
  174. /**
  175.  * Return next entry from a DAV collection.
  176.  * @param dir        argv DIR
  177.  * @return         next entry
  178.  */
  179. /*@dependent@*/ /*@null@*/
  180. struct dirent * davReaddir(DIR * dir)
  181.     /*@globals fileSystem @*/
  182.     /*@modifies fileSystem @*/;
  183.  
  184. /**
  185.  * Create an argv directory from DAV collection.
  186.  * @param path        URL for DAV collection path
  187.  * @return         argv DIR
  188.  */
  189. /*@null@*/
  190. DIR * davOpendir(const char * path)
  191.     /*@globals fileSystem, internalState @*/
  192.     /*@modifies fileSystem, internalState @*/;
  193.  
  194. /**
  195.  * stat(2) clone.
  196.  */
  197. int davStat(const char * path, /*@out@*/ struct stat * st)
  198.     /*@globals fileSystem, internalState @*/
  199.     /*@modifies *st, fileSystem, internalState @*/;
  200.  
  201. /**
  202.  * lstat(2) clone.
  203.  */
  204. int davLstat(const char * path, /*@out@*/ struct stat * st)
  205.     /*@globals fileSystem, internalState @*/
  206.     /*@modifies *st, fileSystem, internalState @*/;
  207.  
  208. #ifdef __cplusplus
  209. }
  210. #endif
  211.  
  212. #endif /* RPMDAV_H */
  213.